namespace('is.app', new function(){

    this.init = function() {
        // Register the upper login button
        is.outlet.register('login', {
            'click': function(event) {
                is.layout.load('east', 'Sign in', '/login.html .panel');
            }
        });

        // Register the login submit actions
        is.outlet.register('login_submit', {
            'click': function(event) {
                var service = event.data.target.attr('href').substring(1);
                console.log('do login for ' + service);
            },
            'submit': function(event) {
                console.log('do local login');
            }
        });

        // Capture the search form
        is.outlet.register('search', {
            'submit': function(event) {
                var text = $('#search_text').val();
                if(text.length > 3) {
                    console.log('do search on ' + text);
                    is.layout.body.toggle('south');
                } else console.log('text too short');
            }
        });


        is.outlet.register('navi', {
            'click': function(event) {
                var panel = event.data.target.attr('panel');
                console.log('open panel ' + panel);
            }
        });
    }

    is.register('init', this);
});
